package com.happy.study.controller;

import com.alibaba.fastjson.JSONObject;
import com.happy.study.entity.CourseEntity;
import com.happy.study.servier.ICourseService;
import com.happy.study.util.ResultBody;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: Wuzh
 * @Description:
 * @Date Created in 15:33 2021/1/23
 * @return
 */
@Controller
@RequestMapping ( "/course" )
public class CourseController {

    @Resource
    private ICourseService iCourseService;

    @RequestMapping ( "/list" )
    @ResponseBody
    public ResultBody<CourseEntity> courseList ( String courseEntity ) {
        CourseEntity course = JSONObject.parseObject ( courseEntity, CourseEntity.class );
        List<CourseEntity> courseEntities = iCourseService.queryList ( course );
        int count = iCourseService.count ( course );
        return ResultBody.success ( courseEntities, count );
    }

}
